<Window x:Class="HelpDeskTool.MainWindow"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:properties="clr-namespace:HelpDeskTool.Properties"
		xmlns:converters="clr-namespace:HelpDeskTool.Converters"
		Title="{x:Static properties:Resources.ru_title}"
		Height="600" MinHeight="300" Width="420" MinWidth="575"
		WindowStartupLocation="CenterScreen"
		ResizeMode="CanResizeWithGrip"
		KeyDown="Window_KeyDown"
		FontFamily="Segoe UI"
		FontSize="12"
		FocusManager.FocusedElement="{Binding ElementName=txtFilter}"
>

	<Window.Resources>
		<converters:WmiInfoConverter x:Key="wmiInfoConverter" />
		<converters:StatusConverter x:Key="statusConverter" />
		<converters:ImageStatusConverter x:Key="imageStatusConverter" />
	</Window.Resources>

	<Grid Margin="5 0" >
		<Grid.RowDefinitions>
			<RowDefinition Height="35"/>
			<RowDefinition/>
			<RowDefinition Height="75"/>
			<RowDefinition Height="30"/>
		</Grid.RowDefinitions>

		<Grid Margin="0 5" Grid.Row="0">
			<Grid.ColumnDefinitions>
				<ColumnDefinition/>
				<ColumnDefinition Width="20"/>
			</Grid.ColumnDefinitions>
			<TextBox Name="txtFilter" Grid.Column="0" TextAlignment="Center" TextChanged="txtFilter_TextChanged" KeyDown="txtFilter_KeyDown" Grid.ColumnSpan="2"/>
			<Image Name="imgRemove" Source="Resources/clear.png" Grid.Column="2" Margin="5" MouseLeftButtonDown="imgRemove_MouseLeftButtonDown">
				<Image.ToolTip>
					<WrapPanel Margin="10">
						<Image Source="Resources/info.png" Margin="5"/>
						<TextBlock Margin="5" Text="{x:Static properties:Resources.ru_imgClear}"/>
					</WrapPanel>
				</Image.ToolTip>
			</Image>
		</Grid>

		<ListView Name="lvComputers"
				ButtonBase.Click="lvComputers_Click"
				ItemsSource="{Binding View}"
				Grid.Row="1"
				ScrollViewer.HorizontalScrollBarVisibility="Hidden">
			<ListView.View>
				<GridView AllowsColumnReorder="True">

					<GridViewColumn Width="20">
						<GridViewColumnHeader Name="Offline"/>
						<GridViewColumn.CellTemplate>
							<DataTemplate>
								<Image Source="{Binding Offline, Converter={StaticResource imageStatusConverter}, TargetNullValue={x:Null}}" Width="8" Height="8"/>
							</DataTemplate>
						</GridViewColumn.CellTemplate>
					</GridViewColumn>

					<GridViewColumn Width="120" DisplayMemberBinding="{Binding Name}">
						<GridViewColumnHeader Name="Name" Content="{x:Static properties:Resources.ru_lvColumnName}"/>
					</GridViewColumn>

					<GridViewColumn Width="150" DisplayMemberBinding="{Binding Description}">
						<GridViewColumnHeader Name="Description" Content="{x:Static properties:Resources.ru_lvColumnDescription}" />
					</GridViewColumn>

					<GridViewColumn Width="60" DisplayMemberBinding="{Binding Phone}">
						<GridViewColumnHeader Name="Phone" Content="{x:Static properties:Resources.ru_lvColumnPhone}" />
					</GridViewColumn>

					<GridViewColumn Width="170" DisplayMemberBinding="{Binding IPaddr, TargetNullValue={x:Static properties:Resources.ru_unaviable}}">
						<GridViewColumnHeader Name="IP" Content="{x:Static properties:Resources.ru_lvColumnIp}" />
					</GridViewColumn>

				</GridView>
			</ListView.View>
			<ListView.ItemContainerStyle>
				<Style TargetType="ListViewItem">
					<EventSetter Event="MouseDoubleClick" Handler="ListViewItem_MouseDoubleClick"/>
					<Setter Property="ToolTipService.ShowDuration" Value="60000"/>
					<Setter Property="ToolTipService.InitialShowDelay" Value="1000"/>
					<Setter Property="ToolTip">
						<Setter.Value>
							<WrapPanel Margin="10">
								<Image Source="Resources/info.png" VerticalAlignment="Top" Margin="10"/>
								<Grid>
									<Grid.RowDefinitions>
										<RowDefinition/>
										<RowDefinition/>
									</Grid.RowDefinitions>
									<Grid.ColumnDefinitions>
										<ColumnDefinition/>
									</Grid.ColumnDefinitions>

									<TextBlock Grid.Row="0" Margin="10">
										<Run Text="{Binding Name, Mode=OneWay}" FontWeight="Bold"/>
										<Run Text="{Binding IPaddr, Mode=OneWay, StringFormat=[ {0} ], TargetNullValue={x:Null}}" FontSize="10" FontWeight="bold"/>
										<Run Text="{Binding Description, Mode=OneWay}" FontStyle="Italic"/>
										<LineBreak/>
										<Run Text="{Binding Hardware, Mode=OneWay, Converter={StaticResource statusConverter}}" FontSize="10"/>
									</TextBlock>
									<TextBlock Margin="10 0" Grid.Row="1" Text="{Binding Hardware, Converter={StaticResource wmiInfoConverter}, Mode=OneWay, TargetNullValue={x:Static properties:Resources.ru_unaviable}}"/>
								</Grid>
							</WrapPanel>
						</Setter.Value>
					</Setter>
					<Style.Triggers>
						<Trigger Property="IsMouseOver" Value="true">
							<Setter Property="FontWeight" Value="Medium"/>
						</Trigger>
					</Style.Triggers>
				</Style>
			</ListView.ItemContainerStyle>
		</ListView>

		<GroupBox Grid.Row="2">
			<GroupBox.Header>
				<Label Content="{x:Static properties:Resources.ru_gbConnection}"/>
			</GroupBox.Header>
			<StackPanel>
				<RadioButton Margin="5" Name="rbMsra" Content="{x:Static properties:Resources.ru_rbMsra}" IsChecked="True"/>
				<RadioButton Margin="5 0" Name="rbRdp" Content="{x:Static properties:Resources.ru_rbRdp}"/>
			</StackPanel>
		</GroupBox>

		<StatusBar Grid.Row="3">
			<StatusBarItem>
				<TextBlock Margin="0">
					<Run Text="{Binding Count, Mode=OneWay, StringFormat=Всего компьютеров: {0}, TargetNullValue={x:Null}}"/>
					<Run Text="{Binding CountOffline, Mode=OneWay, StringFormat=(из них не в сети: {0})}"/>
				</TextBlock>
			</StatusBarItem>
			<StatusBarItem HorizontalAlignment="Right">
				<TextBlock Margin="0">
					<Run FontSize="12" Foreground="Red" Text="El"/>
					<Run FontSize="12" Foreground="Gray" Text="Paco"/>
					<Run FontSize="10" Text="coding team"/>
				</TextBlock>
			</StatusBarItem>
		</StatusBar>
	</Grid>
</Window>
